﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.TMS.Driver.DriverExamine;
using BCDto.TMS.Driver.DriverExamLearn;
using BCDto.TMS.Driver.DriverLearnDatum;
using BCDto.TMS.LearnTrain.DriverLearningTrainRecord;
using BCDto.TMS.LearnTrain.DriverLearningTrainRecord.DriverLearningTrainRecordRequest;
using BCDto.TMS.LearnTrain.PendingLearningVehicle;
using BCService.TMS.Driver.DriverExamLearn;
using BCService.TMS.LearningTrain;
using BCService.TMS.LearningTrain.DriverLearningTrainRecord;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.DriverApp.Driver
{
    /// <summary>
    /// 司机安全培训
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class LearnTrainController : DriverAppBaseController
    {
        private readonly IDriverLearningTrainRecordService driverLearningTrainRecordService;
        private readonly IPendingLearningVehicleService pendingLearningVehicleService;
        public LearnTrainController(IDriverLearningTrainRecordService driverLearningTrainRecordService, IPendingLearningVehicleService pendingLearningVehicleService)
        {
            this.driverLearningTrainRecordService = driverLearningTrainRecordService;
            this.pendingLearningVehicleService = pendingLearningVehicleService;
        }
        /// <summary>
        /// 安全培训,司机签到
        /// </summary>
        /// <param name="requestDto">司机位置信息</param>
        /// <returns></returns>
        [HttpPost("[action]")]
        [Log("安全培训,司机签到")]
        [ProducesResponseType(typeof(DriverLearningTrainRecordDto), 201)]
        public IActionResult Add([FromBody] DriverLearningTrainRecordRequestDto requestDto)
        {
            var result = driverLearningTrainRecordService.Add(requestDto, this.Driver.DriverId);
            return this.Ok(result);
        }

        /// <summary>
        /// 获取培训信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("[action]")]
        [Log("安全培训,司机签到")]
        [ProducesResponseType(typeof(PendingLearningVehicleDto), 201)]
        public IActionResult GetPendingLearningVehicle()
        {
            var result = pendingLearningVehicleService.GetPendingLearningVehicle(this.Driver.DriverId);
            return this.Ok(result);
        }
    }
}